package com.wildworld.core.worldobjects;


import com.wildworld.core.IMap;
import com.wildworld.core.IWorld;
import com.wildworld.core.services.IWorldService;

import javax.sql.rowset.Predicate;
import java.util.UUID;

/**
 * @author gzhebrakov
 *         Date: 26.06.12
 *         Time: 17:01
 */
public class WorldObject {

    private Double x;
    private Double y;
    private Double width;
    private Double height;

    private final String uuid =  UUID.randomUUID().toString();
    private Double health;

    private int r;
    private int g;
    private int b;

    {
        health = 100d;
        x = 0d;
        y = 0d;
        width = 0d;
        height = 0d;
        r = 0;
        g = 0;
        b = 0;
    }

    public final String getUuid(){
        return uuid;
    }

    public void doAction(IMap map, IWorld world){
        //System.out.println(uuid);
    }

    public synchronized void setHealth(Double health){
          if (health != null){
              health += health;
          }
    }

    public Double getHealth(){
        return health;
    }

    public synchronized void move(Double dx, Double dy){
        if (dx != null && dy != null){
            x += dx;
            y += dy;
        }
    }

    public synchronized void setX(Double x){
        if (x != null){
            this.x = x;
        }
    }

    public Double getX(){
        return this.x;
    }

    public synchronized void setY(Double y){
        if (y != null){
            this.y = y;
        }
    }

    public Double getY(){
        return this.y;
    }

    public synchronized void setWidth(Double width){
        if (width != null){
            this.width = width;
        }
    }

    public Double getWidth(){
        return this.width;
    }

    public synchronized void setHeight(Double height){
        if (height != null){
            this.height = height;
        }
    }

    public Double getHeight(){
        return height;
    }

    public void setColor(int r, int g, int b){
        this.r = r;
        this.g = g;
        this.b = b;
    }

    public int [] getColor(){
        return new int[]{r,g,b};
    }

}
